package com.erp.controller.purchaseController;

import com.erp.service.purchaseService.DepotHeadOutService;
import com.erp.utils.Msg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import com.erp.pojo.DepotHead;

@Controller
@RequestMapping("/depotheadout")
public class PurchaseOutController {
    @Autowired
    private DepotHeadOutService depotHeadOutService;
    /*全查/模糊查询*/
    @RequestMapping("select")
    @ResponseBody
    public Msg getAllDepotHead(
            @RequestParam(value = "page",defaultValue = "1")Integer page,
            @RequestParam(value = "limit",defaultValue = "10")Integer limit,
            @RequestParam(value = "number",defaultValue = "")String number,
            @RequestParam(value = "operpersonname",defaultValue = "")String operpersonname,
            Date billTimeBefore,Date billTimeBack){
        try {
            operpersonname = new String(operpersonname.getBytes("iso-8859-1"), "UTF-8");
        }catch (Exception e){ }
        Msg msg = depotHeadOutService.getAllDepotHead(page, limit, number, operpersonname, billTimeBefore, billTimeBack);
        return  msg;
    }
    @PostMapping("/insert")
    public String insertDepotHead(DepotHead depotHead){
        System.out.println("depothead insert");
        depotHeadOutService.addDepotHead(depotHead);
        return "insert success";
    }
    @RequestMapping("/delete")
    public String deleteDepothead(Long id){
        System.out.println("delete");
        depotHeadOutService.deleteDepoetHead(id);
        return "delete success";
    }
}
